package mock.servicesdirectory.services.web.action;

import java.util.ArrayList;
import java.util.List;

import mock.servicesdirectory.common.entities.Service;
import mock.servicesdirectory.services.business.businessimpl.ServiceBo;
import mock.servicesdirectory.services.business.businessinterface.IServiceBo;
import mock.servicesdirectory.services.dao.daoimpl.ServiceDao;

import com.opensymphony.xwork2.ActionSupport;

public class ServiceListAction extends ActionSupport {

	private List<Service> gridModel;
	private Integer rows = 0;
	private Integer page = 0;
	private String sord;
	private String sidx;
	private String searchField;
	private String searchString;
	private String searchOper;
	private Integer total = 0;
	private Integer records = 0;
	private IServiceBo serviceBo;

	public Integer getPage() {
		return page;
	}

	public void setPage(Integer page) {
		this.page = page;
	}

	public Integer getTotal() {
		return total;
	}

	public void setTotal(Integer total) {
		this.total = total;
	}

	public String getSearchOper() {
		return searchOper;
	}

	public void setSearchOper(String searchOper) {
		this.searchOper = searchOper;
	}

	public String getSearchString() {
		return searchString;
	}

	public void setSearchString(String searchString) {
		this.searchString = searchString;
	}

	public String getSearchField() {
		return searchField;
	}

	public void setSearchField(String searchField) {
		this.searchField = searchField;
	}

	public String getSidx() {
		return sidx;
	}

	public void setSidx(String sidx) {
		this.sidx = sidx;
	}

	public String getSord() {
		return sord;
	}

	public void setSord(String sord) {
		this.sord = sord;
	}

	public List<Service> getGridModel() {
		return gridModel;
	}

	public void setGridModel(List<Service> gridModel) {
		this.gridModel = gridModel;
	}

	public String execute() {
		records = 30;
		rows = 10;
		List<Service> service = new ArrayList<Service>();
		service = serviceBo.listService("", true);

		setGridModel(service);

		setTotal((int) Math.ceil((double) records / (double) rows));

		return SUCCESS;
	}

	public String getJSON() {
		return execute();
	}

	public String copy() {

		return SUCCESS;
	}

	public String create() {
		return SUCCESS;
	}

	public String listServices() {
		return SUCCESS;
	}

	public Integer getRows() {
		return rows;
	}

	public void setRows(Integer rows) {
		this.rows = rows;
	}

	public Integer getRecords() {
		return records;
	}

	public void setRecords(Integer records) {
		this.records = records;
	}

	public IServiceBo getServiceBo() {
		return serviceBo;
	}

	public void setServiceBo(IServiceBo serviceBo) {
		this.serviceBo = serviceBo;
	}

}